package nc.ui.budget.tools.fake;

import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillScrollPane;
import nc.ui.trade.buffer.BillUIBuffer;
import nc.ui.trade.button.ButtonManager;
import nc.ui.trade.manage.BillManageUI;
import nc.ui.trade.manage.ManageEventHandler;

public class FakeUI {
	protected BillManageUI manageUI = null;
	protected ManageEventHandler eventHandler = null;
	protected void	setBodyValueAt(Object aValue,int row,String strKey){
		manageUI.getBillCardPanel().setBodyValueAt(aValue, row, strKey);
	}
	
	protected String myGetHeaditem(String name) {
		if (getBillCardPanel().getHeadItem(name) != null) {
			return getBillCardPanel().getHeadItem(name).getValue();
		}
		return null;
	}

	protected String myGetBodyValue(int row, String name) {
		if (getBillCardPanel().getBodyValueAt(row, name) != null) {
			return getBillCardPanel().getBodyValueAt(row, name).toString();
		}
		return null;
	}

	protected BillCardPanel getBillCardPanel() {
		return manageUI.getBillCardPanel();
	}

	protected ButtonManager getButtonManager() {
		return manageUI.getButtonManager();
	}

	protected void updateButtons() {
		manageUI.updateButtons();
	}

	protected BillUIBuffer getBufferData() {
		return manageUI.getBufferData();
	}

	public void delAllLine() {
		int rowCount = getBillCardPanel().getRowCount();
		getBillCardPanel().stopEditing();
		BillScrollPane bsp = getBillCardPanel().getBodyPanel();
		int[] rows = new int[rowCount];
		for (int i = 0; i < rowCount; i++) {
			rows[i] = i;
		}
		bsp.delLine(rows);
	}
	protected Double getDoubleValue(int row, String key) {
		Double returnvalue = null;
		Object bodyvalue = getBillCardPanel().getBodyValueAt(row, key);
		if (bodyvalue != null) {
			returnvalue = Double.parseDouble(bodyvalue.toString());
		}
		return returnvalue;
	}

	protected double getDoubleValue(Object bodyvalue) {
		double returnvalue = 0;
		if (bodyvalue != null) {
			returnvalue = Double.parseDouble(bodyvalue.toString());
		}
		return returnvalue;
	}
	protected void showWarningMessage(String arg0) {
		manageUI.showWarningMessage(arg0);
	}
}
